"""
Run through the test-basic script.

This should really be broken out into multiple sub scripts...
"""

import os
import getpass
import twilltestlib

def setup_module():
    global url
    url = twilltestlib.get_url()

# for python2.6, bypass getpass.getpass which reads from /dev/tty
def _my_getpass(prompt):
    return 'unique2'

def test():
    _old_getpass, getpass.getpass = getpass.getpass, _my_getpass
    inp = "unique1\n"
    try:
        twilltestlib.execute_twill_script('test-basic.twill', inp,
                                          initial_url=url)
    finally:
        getpass.getpass = _old_getpass
    
def teardown_module():
    try:
        os.unlink(os.path.join(twilltestlib.testdir, 'test-basic.cookies'))
    except OSError:
        pass
